API - Cache\Cache
system\cache.php at line 1137

Class Cache

Cache

public class Cache

Multi-layer universal cache controller for Cotonti
Property-read:
bool $mem_available Memory storage availability flag

Field Summary
private array

$bindings

Event bindings

Db_cache_driver

$db

Intermediate database cache driver.

Static_cache_driver

$disk

Persistent cache underlayer driver.

Temporary_cache_driver

$mem

Mutable top-layer shared memory driver.

Page_cache

$page

Page cache driver.

private bool

$resync_on_exit

A flag to apply binding changes before termination

private string

$selected_drv

Selected memory driver

Constructor Summary
void

__construct()

Initializes Page cache for early page caching

Method Summary
mixed

__get(string name)

Property handler

void

init()

Initializes the rest Cache components when the sources are available

private void

resync_bindings()

Rereads bindings from database

bool

bind(string event, string id, string realm, int type)

Binds an event to automatic cache field invalidation

int

bind_array(array bindings)

Binds multiple cache fields to events, all represented as an associative array Binding keys: event - name of the event the field is binded to id - cache object id realm - cache realm name type - cache storage type, one of COT_CACHE_TYPE_* constants

bool

clear(int type)

Clears all cache entries

void

clear_realm(string realm, int type)

Clears cache in specific realm

array

get_info()

Returns information about memory driver usage

int

trigger(string event)

Invalidates cache cells which were binded to the event.

int

unbind(string realm, string id)

Removes event/cache bindings

Field Detail

system\cache.php at line 1168

bindings

private array $bindings
Event bindings

system\cache.php at line 1151

db

public Db_cache_driver $db
Intermediate database cache driver. It is recommended to use memory cache for particular objects rather than DB cache.

system\cache.php at line 1145

disk

public Static_cache_driver $disk = COT_DEFAULT_TTL
Persistent cache underlayer driver. Stores disk-only cache entries. Use it for large objects, which you don't want to put into memory cache.

system\cache.php at line 1157

mem

public Temporary_cache_driver $mem
Mutable top-layer shared memory driver. Is FALSE if memory cache is not available

system\cache.php at line 1163

page

public Page_cache $page
Page cache driver. Is FALSE if page cache is disabled

system\cache.php at line 1173

resync_on_exit

private bool $resync_on_exit = false
A flag to apply binding changes before termination

system\cache.php at line 1178

selected_drv

private string $selected_drv = ''
Selected memory driver

Constructor Detail

system\cache.php at line 1183

__construct

public void __construct()
Initializes Page cache for early page caching

Method Detail

system\cache.php at line 1206

__get

public mixed __get(string name)
Property handler
Parameters:
name - Property name
Returns:
Property value

system\cache.php at line 1227

init

public void init()
Initializes the rest Cache components when the sources are available

system\cache.php at line 1275

resync_bindings

private void resync_bindings()
Rereads bindings from database

system\cache.php at line 1296

bind

public bool bind(string event, string id, string realm, int type)
Binds an event to automatic cache field invalidation
Parameters:
event - Event name
id - Cache entry id
realm - Cache realm name
type - Storage type, one of COT_CACHE_TYPE_* values
Returns:
TRUE on success, FALSE on error

system\cache.php at line 1323

bind_array

public int bind_array(array bindings)
Binds multiple cache fields to events, all represented as an associative array Binding keys: event - name of the event the field is binded to id - cache object id realm - cache realm name type - cache storage type, one of COT_CACHE_TYPE_* constants
Parameters:
bindings - An indexed array of bindings. Each binding is an associative array with keys: event, realm, id, type.
Returns:
Number of bindings added

system\cache.php at line 1352

clear

public bool clear(int type)
Clears all cache entries
Parameters:
type - Cache storage type: COT_CACHE_TYPE_ALL, COT_CACHE_TYPE_DB, COT_CACHE_TYPE_DISK, COT_CACHE_TYPE_MEMORY.
Returns:

system\cache.php at line 1393

clear_realm

public void clear_realm(string realm, int type)
Clears cache in specific realm
Parameters:
realm - Realm name
type - Cache storage type: COT_CACHE_TYPE_ALL, COT_CACHE_TYPE_DB, COT_CACHE_TYPE_DISK, COT_CACHE_TYPE_MEMORY.

system\cache.php at line 1431

get_info

public array get_info()
Returns information about memory driver usage
Returns:
Usage information

system\cache.php at line 1448

trigger

public int trigger(string event)
Invalidates cache cells which were binded to the event.
Parameters:
event - Event name
Returns:
Number of cells cleaned

system\cache.php at line 1497

unbind

public int unbind(string realm, string id)
Removes event/cache bindings
Parameters:
realm - Realm name (required)
id - Object identifier. Optional, if not specified, all bindings from the realm are removed.
Returns:
Number of bindings removed